﻿/*
 *  BlackJack Simulator
 *  Feb 3rd 2013
 * 
 *  Menu Screen
 * 
 * 
 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BlackjackSimulator
{
    public partial class frmBlackJackMain : Form
    {
        public static frmBlackJackMain staticVar = null;

        public frmBlackJackMain()
        {
            InitializeComponent();
            this.drpDeckCount.SelectedIndex = 0;
            this.drpOpponentCount.SelectedIndex = 0;
            this.drpWages.SelectedIndex = 0;
        }

        public void setDefaultSettings()
        {
            drpDeckCount.SelectedIndex = 0;
            drpOpponentCount.SelectedIndex = 1;
            drpWages.SelectedIndex = 1;
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            //closes the form
            Close();
        }

        private void frmBlackJackMain_Load(object sender, EventArgs e)
        {
            //Set the default game settings on the dropdown boxes when the form loads.
            //Call default setting function which will change the index of the dropdown menus
            setDefaultSettings();
            //Set focus on btn start
            this.ActiveControl = btnStart;
            
        }

        private void btnDefaultSettings_Click(object sender, EventArgs e)
        {
            // Call set default function
            setDefaultSettings();
        }

        private int getPlayerCount()
        {
            switch (this.drpOpponentCount.SelectedIndex)
            {
                case 0:
                    return 1;
                case 1:
                    return 2;
                case 2:
                    return 3;
                case 3:
                    return 4;
                case 4:
                    return 5;
                case 5:
                    return 6;
                default:
                    return 0;
            }
        }

        private int getWage()
        {
            switch (this.drpWages.SelectedIndex)
            {
                case 0:
                    return 5;
                case 1:
                    return 10;
                case 2:
                    return 15;
                case 3:
                    return 20;
                case 4:
                    return 25;
                case 5:
                    return 50;
                case 6:
                    return 100;
                default:
                    return 5;
            }
        }

        private int getDeckCount()
        {
            switch (this.drpDeckCount.SelectedIndex)
            {
                case 0:
                    return 1;
                case 1:
                    return 2;
                case 2:
                    return 4;
                case 3:
                    return 6;
                case 4:
                    return 8;
                default:
                    return 1;
            }
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            // display the game screen form and hide the main setting screen
            staticVar = this;
            staticVar.Hide();
            int playerCount = getPlayerCount();
            int wage = getWage();
            int deckCount = getDeckCount();
            frmGameScreen gameForm = new frmGameScreen(playerCount, wage, deckCount);
            gameForm.main = this;
            gameForm.ShowDialog();            
        }
    }
}
